package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.ReturnList;
import com.atguigu.jxc.service.ReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author: dongdong lau
 * @CreateTime: 2021/7/24 10:46
 * @Description: 退货出库controller层接口
 */
@RestController
@RequestMapping(value = "/returnListGoods")
public class ReturnController {

    @Autowired
    private ReturnService returnService;

    @RequestMapping(value = "/save")
    public ServiceVO save(@RequestParam String returnNumber,
                          ReturnList returnList,
                          String returnListGoodsStr){
        // 从请求url中获取returnNumber设置进returnList
        returnList.setReturnNumber(returnNumber);
        // 调用保存接口
        ServiceVO save = returnService.save(returnList, returnListGoodsStr);
        // 返回结果
        return save;
    }

    /**
     * 退货单列表展示
     * @param returnNumber
     * @param supplierId
     * @param state
     * @param sTime
     * @param eTime
     * @return
     */
    @RequestMapping("/list")
    public Map<String, Object> list(String returnNumber, Integer supplierId, Integer state, String sTime, String eTime){
        Map<String, Object> map = returnService.list(returnNumber, supplierId, state, sTime, eTime);
        return map;
    }

    /**
     * 查询商品信息
     * @param returnListId
     * @return
     */
    @RequestMapping("/goodsList")
    public Map<String, Object> getReturnListGoodsById(@RequestParam Integer returnListId){
        return returnService.getReturnListGoodsById(returnListId);
    }

    /**
     * 根据returnListId删除出货单信息
     * @param returnListId
     * @return
     */
    @RequestMapping("delete")
    public ServiceVO deletePurchaseListById(@RequestParam Integer returnListId){
        return returnService.deleteReturnListById(returnListId);
    }
}
